package com.student.status.action;

import com.opensymphony.xwork2.ActionSupport;
import com.student.status.model.UserInfoEntity;
import com.student.status.service.UserService;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@Scope("prototype")
public class CommunalAction extends ActionSupport {
    private ModelMap mymp;
    @Autowired
    private UserService userService;

    public ModelMap getModelMap() {
        return mymp;
    }
    public void setModelMap(ModelMap mymp) {
        this.mymp = mymp;
    }

    public String login(){
        return "success";
    }

    public String admin(){
        try {
            HttpSession session = ServletActionContext.getRequest().getSession(true);
            session.setAttribute("user_leve", "0");
        }catch (Exception e) {
            e.printStackTrace();
        }
        return "success";
    }

    public String teacher(){
        try {
            HttpSession session = ServletActionContext.getRequest().getSession(true);
            session.setAttribute("user_leve", "1");
        }catch (Exception e) {
            e.printStackTrace();
        }
        return "success";
    }

    public String user(){
        try {
            HttpSession session = ServletActionContext.getRequest().getSession(true);
            session.setAttribute("user_leve", "2");
        }catch (Exception e) {
            e.printStackTrace();
        }
        return "success";
    }

    public String error(){
        return "error";
    }

    public String administrationManagement(){
        try {
            List<UserInfoEntity> userBean = userService.selectAll();
            if (userBean != null){
                HttpSession session = ServletActionContext.getRequest().getSession();
                session.setAttribute("alluser", userBean);
            }
        }catch (Exception e) {
            e.printStackTrace();
        }
        return "success";
    }

    public String addUsers(){
        return "success";
    }

    public String adminUpdateUsers(){
        return "success";
    }

    public String changePassword(){
        return "success";
    }

    public String personalData(){
        return "success";
    }

    public String assistance(){
        return "success";
    }

    public String studentInformation(){
        return "success";
    }

    public String curriculaVariable(){
        return "success";
    }

    public String viewTheResults(){
        return "success";
    }

    public String viewTheCourseSelection(){
        return "success";
    }

    public String studentManagement(){
        return "success";
    }

    public String classManagement(){
        return "success";
    }

    public String studentInformationManagement(){
        return "success";
    }

    public String offerCourses(){
        return "success";
    }

    public String registrationRecord(){
        return "success";
    }


}
